package open.tech.dawn.web.core.support;

import lombok.Data;
import open.tech.dawn.web.core.entity.Code;

@Data
public class Result {

    private int code;

    private String message;

    private Object data;

    public static Result createSuccess(Object data) {
        Result result = new Result();
        result.setCode(Code.service_success);
        result.setMessage("请求成功");
        result.setData(data);
        return result;
    }

    public static Result createSuccess(String message, Object data) {
        Result result = new Result();
        result.setCode(Code.service_success);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static Result createSuccess() {
        Result result = new Result();
        result.setCode(Code.service_success);
        result.setMessage("请求成功");
        return result;
    }

    public static Result createSuccessData(Object data) {
        Result result = new Result();
        result.setCode(Code.service_success);
        result.setMessage("请求成功");
        result.setData(data);
        return result;
    }

    public static Result createError() {
        Result result = new Result();
        result.setCode(Code.service_error);
        result.setMessage("请求失败");
        return result;
    }

    public static Result createError(String message) {
        Result result = new Result();
        result.setCode(Code.service_error);
        result.setMessage(message);
        return result;
    }

}
